#include "pch.h"

#include <windows.h>
#include <string>

sol9::application* app = nullptr;
sol9::vector2df mouse;
sol9::polygon_ptr p;

LRESULT CALLBACK procedure(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);

void initialize();
void cleanup();
void update(sol9::u32 t);
void render();

void main()
{
	std::tstring title = L"reMakes";
	sol9::dimension2du size(800, 600);

	app = new sol9::application(title, size, procedure);
	app->createRenderer();

	initialize();

	while (app->run())
	{
		update(app->tick());
		render();
	}

	cleanup();
}

LRESULT CALLBACK procedure(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
	switch (Msg)
	{
	case WM_MOUSEMOVE :
		mouse.x = LOWORD(lParam);
		mouse.y = HIWORD(lParam);
		break;
	case WM_KEYDOWN :
		if (wParam == VK_ESCAPE)
			PostQuitMessage(0);
		break;

	case WM_DESTROY :
		PostQuitMessage(0);
		break;

	default:
		return DefWindowProc(hWnd, Msg, wParam, lParam);
	}

	return 0;
}

void initialize()
{
	sol9::polygonizer pmgr;
	p = pmgr.create(25, 200.0f);

	sol9::matrix3 m(sol9::matrix3::identity);
	sol9::matrix3 n;
}

void cleanup()
{
}

void update(sol9::u32 t)
{
	//std::cout << t << std::endl;
}

void render()
{
	sol9::renderer_ptr renderer = app->getRenderer();
	renderer->beginScene();

	renderer->draw(p);

	renderer->endScene();
}
